﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Entity;

namespace ETL.DataAccess
{
    public class ProjectEngineerRepository
    {
        //get other engineers in the selected project
        public IEnumerable<SCHEDULED_RESOURCE_USAGES> GetOtherEngineers (int? projectId, string currentUser)
        {
            var db = new ETLDataEntities();

            if (projectId != null)
            {
                var otherEngineers = from e in db.SCHEDULED_RESOURCE_USAGES
                                     join p in db.PROJECTS on e.PROJECT_NAME equals p.PROJECT_NAME 
                                     where p.PROJECT_ID == (short)projectId
                                           && e.PROJECT_NAME != currentUser
                                     orderby e.RESOURCE_ID
                                     select e;
                   
                return otherEngineers;
            }
            else return null;
        }
    }
}
